package ndk.sskj.com.mvpretrofitokhttprxjava.mvp.view;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import ndk.sskj.com.mvpretrofitokhttprxjava.HttpServiceInterface;
import ndk.sskj.com.mvpretrofitokhttprxjava.R;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class RetrofitTestActivity extends BaseActivity<RetrofitTestPresenter> {
    @BindView(R.id.tv_content)
    TextView tvContent;
    private String baseUrl = "http://centbtc.com";
    private File file;


    @Override
    protected int getLayoutId() {
        return R.layout.activity_retrofit_test;
    }

    @Override
    protected void initView() {

        Bitmap bitmap = null;

        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
            Drawable vectorDrawable = getDrawable(R.mipmap.ic_launcher);
            bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(),
                    vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
            Canvas canvas = new Canvas(bitmap);
            vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
            vectorDrawable.draw(canvas);
        } else {
            bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
        }

        file = new File(getFilesDir() + "first.png");
        FileOutputStream fileOutputStream;
        try {
            fileOutputStream = new FileOutputStream(file);
            bitmap.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

    }

    @Override
    protected void initData() {
        mPresenter.retrofitRequest( file);
    }

    @Override
    protected RetrofitTestPresenter getPresenetr() {
        return new RetrofitTestPresenter();
    }

}
